package com.xqboss.apps.service.user;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xqboss.apps.domain.punch.UserTeamSettleRecord;
import com.xqboss.apps.dto.punch.UserTeamIncomeRecordDto;
import com.xqboss.apps.mapper.punch.UserTeamSettleRecordMapper;
import com.xqboss.apps.vo.punch.UserTeamIncomeRecordVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Trent
 * @date 2023/9/8
 */
@Service
public class UserTeamSettleRecordService extends ServiceImpl<UserTeamSettleRecordMapper, UserTeamSettleRecord> {


    /**
     * 获取用户队伍收益记录
     * @param userId
     */
    public List<UserTeamIncomeRecordVo> getUserTeamIncomeRecord(UserTeamIncomeRecordDto dto){
        List<UserTeamIncomeRecordVo> list = baseMapper.getTeamIncomeRecord(dto);
        return list;
    }

    /**
     * 将所有记录置为已读
     * @param userId
     */
    public void setAllRead(Long userId) {
        update(new LambdaUpdateWrapper<UserTeamSettleRecord>()
                .set(UserTeamSettleRecord::getIsRead, true)
                .eq(UserTeamSettleRecord::getUserId, userId));
    }
}
